﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BeatingMole
{
    class CBusLoadAndSaveGame
    {
        #region "Variable"
        /// <summary>
        /// Lớp thông tin Game
        /// </summary>
        CInfoLoadAndSaveGame InfoLoadAndSaveGame;
        /// <summary>
        /// Đối tượng quản lý Resource
        /// </summary>
        ContentManager _Content;
        /// <summary>
        /// Bật/tắt Update và Draw
        /// </summary>
        bool _isEnable;
        bool _isBack = false;
        MouseState MouseCur;
        MouseState MousePre;
        #endregion

        #region "Properties"
        public bool IsBack
        {
            set { _isBack = value; }
            get { return _isBack; }
        }
        public bool IsEnable
        {
            set { _isEnable = value; }
            get { return _isEnable; }
        }
        #endregion

        #region "Constructor"
        public CBusLoadAndSaveGame(ContentManager content)
        {
            _Content = content;
            InfoLoadAndSaveGame = new CInfoLoadAndSaveGame(_Content);
            IsEnable = false;
        }
        public bool IsBackMenu()
        {
            if (IsBack == true)
                return true;
            return false;
        }
        public void Update(GameTime gameTime)
        {
            if (IsEnable == true)
            {
                MouseCur = Mouse.GetState();
                if (MouseCur.LeftButton == ButtonState.Pressed && MousePre.LeftButton == ButtonState.Released)
                {
                    if (new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 1, 1).Intersects(InfoLoadAndSaveGame.RecBtnBack))
                    {
                        IsEnable = false;
                        IsBack = true;
                        IsBackMenu();
                    }
                }
                MousePre = MouseCur;
            }
        }
        public void Draw(SpriteBatch spriteBatch)
        {
            if (IsEnable == true)
            {
                spriteBatch.Draw(InfoLoadAndSaveGame.BgSaveAndLoadGame, Vector2.Zero, Color.White);
                spriteBatch.Draw(InfoLoadAndSaveGame.BgBlack, Vector2.Zero, Color.Black * 0.75f);
                spriteBatch.Draw(InfoLoadAndSaveGame.BtnBack, new Vector2(720, 10), Color.White);
                spriteBatch.Draw(InfoLoadAndSaveGame.BtnPre, new Vector2(50, 110), Color.White);
                spriteBatch.Draw(InfoLoadAndSaveGame.BtnNext, new Vector2(150, 110), Color.White);
            }
        }
        #endregion
    }
}
